#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/10/9 22:50
# @function: the script is used to do something.
# @version :

"""
计算1 -100的累加和
"""
# 计数器
i = 1
sum_res = 0

while i <= 100:
    # sum_res = sum_res + i
    sum_res += i
    i += 1

print(f'计算结果：{sum_res}')

"""
计算1 - 100 之间偶数的累计和
"""
i = 1
sum_res = 0

while i <= 100:
    if i % 2 == 0:  # 判断当前计数器中的值是否为偶数
        sum_res += i
    i += 1

print(f'计算结果：{sum_res}')
"""
计算1 -100 之间能被3整除并且能被7整除的所有数字的和
"""
i = 1
sum_res = 0

while i <= 100:
    if i % 3 == 0 and i % 7 == 0:  # 判断当前计数器中的值是否为偶数
        sum_res += i
    i += 1

print(f'计算结果：{sum_res}')


"""
通过循环的方式输出以下格式数据：
    1 --> 1
    2 --> 4
    3 --> 9
    4 --> 16
"""
i = 1
while i <=4:
    print(f'{i} --> {i**2}')
    i += 1
